package com.livesource.client.web.sourceCode.viewOptions;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupPanel;
import com.livesource.client.LiveSourceGlobalVariables;
import com.livesource.client.model.entry.ProjectClass;
import com.livesource.client.web.sourceCode.testing.UnitTestView;

/**
 * 
 * @UserInterface
 */
public class ButtonTest extends HTML {

	public static final String imageUnpressed = "<a href='#'><img src='"
			+ GWT.getModuleName() + "/liveSource/images/test.gif'></a>";

	public static final String imagePressed = "<a href='#'><img src='"
			+ GWT.getModuleName()
			+ "/liveSource/images/testHighlighted.gif'></a>";

	public PopupPanel testHint;

	public ButtonTest(final ProjectClass entry) {

		this.setHTML(imageUnpressed);

		this.setTitle("Test");

		this.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {

				OptionsIcons.toggledButtons(entry);
				OptionsIcons.buttonTest.setHTML(imagePressed);

				String testClassPath = entry.getFilePath().replace("src/",
						"test/")
						+ "/" + entry.getClassName() + "Test.java";

				ProjectClass testClass = LiveSourceGlobalVariables.projectEntries
						.get(testClassPath);

				new UnitTestView(entry, testClass);
			}
		});

		/*
		 * testHint = HelpHint.getHelpHintLinked(this.getClass().getName(),
		 * internationalizationConstants.test(), GlobalVariables.locale);
		 * 
		 * this.addMouseOverHandler(new MouseOverHandler() {
		 * 
		 * @Override public void onMouseOver(MouseOverEvent event) {
		 * 
		 * OptionsIcons.hideHints();
		 * 
		 * HelpHint.executeMouseOverHandler(event, testHint, null);
		 * 
		 * } });
		 */
	}
}
